package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.jsonResult.JsonResult;
import cn.tedu.charging.common.pojo.jsonResult.param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.jsonResult.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("device")
@Api(tags = "设备模块")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 获取场站信息
     * 入参： 枪id 桩id
     * 出参： 场站信息的VO
     * 请求方式：GET
     */
    @ApiOperation(value = "获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable Integer gunId){
        log.debug("获取场站信息-入参:{}",gunId);
        log.debug("获取场站信息-service-入参:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        log.debug("获取场站信息-service-入参:{},出参:{}",gunId,stationInfoVO);
        JsonResult<StationInfoVO> result = JsonResult.ok(stationInfoVO, "获取场站信息成功");
        log.debug("获取场站信息-service-入参:{},出参:{}",gunId,result);
        return result;
    }
    @ApiOperation(value = "更新枪状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("更新枪状态-入参:{}",param);
        log.debug("更新枪状态-service-入参:{}",param);
        Boolean result = deviceService.updateGunStatus(param);
        log.debug("更新枪状态-service-入参:{},出参:{}",param,result);
        JsonResult jsonResult = JsonResult.ok(result, "更新枪状态成功");
        log.debug("更新枪状态-入参:{},出参:{}",param,jsonResult);
        return jsonResult;
    }
}
